//
//  GTHttpManager.h
//  GTNetWorking
//
//  Created by Mr.Wei on 2021/2/23.
//

#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN

@interface GTHttpManager : NSObject

@property (readonly, nonatomic, strong, nullable) NSURL *baseURL;

//回调队列，默认nil，在主队列回调
@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue;

/// 初始化 
+ (instancetype)manager;

/// 如果所有的请求都拥有相同的baseURL，就在这里初始化吧
/// @param url baseURL
- (instancetype)initWithBaseURL:(nullable NSURL *)url;

/// 指定初始化函数
/// @param url baseURL
/// @param configuration 如果为空则使用defaultSessionConfiguration
- (instancetype)initWithBaseURL:(nullable NSURL *)url
           sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;

/// GET 请求
/// @param URLString 拼在BaseURL的后面，或者自己本身就是完整的URL
/// @param parameters 参数
/// @param headers 请求头
/// @param success 成功回调
/// @param failure 失败回调
- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
                            parameters:(nullable id)parameters
                               headers:(nullable NSDictionary <NSString *, NSString *> *)headers
                               success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
                               failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;

/// POST 请求
/// @param URLString 拼在BaseURL的后面，或者自己本身就是完整的URL
/// @param parameters 参数
/// @param headers 请求头
/// @param success 成功回调
/// @param failure 失败回调
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
                             parameters:(nullable id)parameters
                                headers:(nullable NSDictionary <NSString *, NSString *> *)headers
                                success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
                                failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
@end

NS_ASSUME_NONNULL_END
